#!/bin/bash

CUR_DIR=$(pwd)
QT_DIR=${CUR_DIR}/../../..

pushd ${QT_DIR} > /dev/null

cp ${QT_DIR}/qtsm-sdk-c/samples/Dockerfile.sdk .
wget https://repo.huaweicloud.com/hce/2.0/os/x86_64/Packages/libcbor-0.9.0-0.hce2.x86_64.rpm
wget https://repo.huaweicloud.com/hce/2.0/os/x86_64/Packages/cjson-1.7.15-1.hce2.x86_64.rpm
wget https://repo.huaweicloud.com/hce/2.0/os/x86_64/Packages/cjson-devel-1.7.15-1.hce2.x86_64.rpm
wget https://repo.huaweicloud.com/hce/2.0/os/x86_64/Packages/libcbor-devel-0.9.0-0.hce2.x86_64.rpm
wget https://repo.huaweicloud.com/hce/2.0/os/x86_64/Packages/libqtsm-devel-1.0.0-2.hce2.x86_64.rpm
wget https://repo.huaweicloud.com/euler/2.9/os/x86_64/updates/json-c-0.13.1-7.h3.eulerosv2r9.x86_64.rpm
wget https://repo.huaweicloud.com/euler/2.9/os/x86_64/updates/json-c-devel-0.13.1-7.h3.eulerosv2r9.x86_64.rpm

docker build -f Dockerfile.sdk -t ubuntusdk .
rm ./Dockerfile.sdk
rm *.rpm

qt enclave make-img --docker-uri ubuntusdk --eif ${CUR_DIR}/sdkdecrypt.eif

popd > /dev/null